package edu.ucsd.cse135.gas.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class IndexAction extends Action {

	private static final String APPLICANT = "applicant";
	private static final String ADMIN = "admin";
	private static final String CHAIR = "chair";
	private static final String REVIEWER = "reviewer";
	private static final String FAILURE = "failure";
	
	public IndexAction() {
		super();
	}
	
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

			if(request.isUserInRole(APPLICANT))
			{
				return mapping.findForward(APPLICANT);
			}
			else if(request.isUserInRole(ADMIN))
			{
				return mapping.findForward(ADMIN);
			}
			else if(request.isUserInRole(CHAIR))
			{
				return mapping.findForward(CHAIR);
			}
			else if(request.isUserInRole(REVIEWER))
			{
				return mapping.findForward(REVIEWER);
			}
			else
			{
				return mapping.findForward(FAILURE);
			}
	}
}
